package com.ty.controller;

import com.ty.entity.Category;
import com.ty.entity.CategoryQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ty.service.CategoryService;

import java.util.List;

@RestController
@RequestMapping("/api/category")
public class CategoryController{
    @Autowired
    private CategoryService categoryService;

    /**
     * 查询接口
     */
    @GetMapping
    public List<Category> select(CategoryQuery query){
        //F5  跳到下一个断点     F9
        //F10  下一步            F8
        //F11  进入方法体内      F7
        return categoryService.select(query);
    }

    @PostMapping
    public Integer insert(@RequestBody Category product){
        return categoryService.insert(product);
    }

    @PutMapping
    public Integer update(@RequestBody Category product){
        return categoryService.update(product);
    }

    @DeleteMapping
    public Integer delete(Integer id){
        return categoryService.delete(id);
    }
}